package com.joolun.weixin.service.impl;

import java.util.List;

import com.joolun.common.corp.TenantContext;
import com.joolun.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.stereotype.Service;
import com.joolun.weixin.mapper.ZbRedEnvelopesMapper;
import com.joolun.weixin.entity.ZbRedEnvelopes;
import com.joolun.weixin.service.IZbRedEnvelopesService;

/**
 * 直播间红包Service业务层处理
 * 
 * @author joolun
 * @date 2025-06-05
 */
@Service
public class ZbRedEnvelopesServiceImpl extends  ServiceImpl<ZbRedEnvelopesMapper, ZbRedEnvelopes> implements IZbRedEnvelopesService
{
    @Autowired
    private ZbRedEnvelopesMapper zbRedEnvelopesMapper;

    /**
     * 查询直播间红包
     * 
     * @param id 直播间红包主键
     * @return 直播间红包
     */
    @Override
    public ZbRedEnvelopes selectZbRedEnvelopesById(Long id)
    {
        return zbRedEnvelopesMapper.selectZbRedEnvelopesById(id);
    }

    /**
     * 查询直播间红包列表
     * 
     * @param zbRedEnvelopes 直播间红包
     * @return 直播间红包
     */
    @Override
    public List<ZbRedEnvelopes> selectZbRedEnvelopesList(ZbRedEnvelopes zbRedEnvelopes)
    {
        // 添加主体id
        zbRedEnvelopes.setCorpId(TenantContext.getTenantId());
        return zbRedEnvelopesMapper.selectZbRedEnvelopesList(zbRedEnvelopes);
    }

    /**
     * 新增直播间红包
     * 
     * @param zbRedEnvelopes 直播间红包
     * @return 结果
     */
    @Override
    public int insertZbRedEnvelopes(ZbRedEnvelopes zbRedEnvelopes)
    {
        // 添加主体id
        zbRedEnvelopes.setCorpId(TenantContext.getTenantId());
        zbRedEnvelopes.setCreateTime(DateUtils.getNowDate());
        return zbRedEnvelopesMapper.insertZbRedEnvelopes(zbRedEnvelopes);
    }

    /**
     * 修改直播间红包
     * 
     * @param zbRedEnvelopes 直播间红包
     * @return 结果
     */
    @Override
    public int updateZbRedEnvelopes(ZbRedEnvelopes zbRedEnvelopes)
    {
        zbRedEnvelopes.setUpdateTime(DateUtils.getNowDate());
        return zbRedEnvelopesMapper.updateZbRedEnvelopes(zbRedEnvelopes);
    }

    /**
     * 批量删除直播间红包
     * 
     * @param ids 需要删除的直播间红包主键
     * @return 结果
     */
    @Override
    public int deleteZbRedEnvelopesByIds(Long[] ids)
    {
        return zbRedEnvelopesMapper.deleteZbRedEnvelopesByIds(ids);
    }

    /**
     * 删除直播间红包信息
     * 
     * @param id 直播间红包主键
     * @return 结果
     */
    @Override
    public int deleteZbRedEnvelopesById(Long id)
    {
        return zbRedEnvelopesMapper.deleteZbRedEnvelopesById(id);
    }
}
